/*
 Copyright (C) 2007 - Michael Opitz
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
#ifndef _GMAIL_LIST
#define _GMAIL_LIST

#include <glib-object.h>
#include <glib.h>
#include "gmail.h"

G_BEGIN_DECLS

#define GMAIL_TYPE_LIST 		 gmail_list_get_type ()
#define GMAIL_LIST(obj) 		(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
				         GMAIL_TYPE_LIST, GmailList))
#define GMAIL_LIST_CLASS(klass) 	(G_TYPE_CHECK_CLASS_CAST ((klass), \
					 GMAIL_TYPE_LIST, GmailListClass))
#define GMAIL_IS_LIST(obj) 		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
				         GMAIL_TYPE_LIST))
#define GMAIL_IS_LIST_CLASS(klass)  	(G_TYPE_CHECK_CLASS_TYPE ((klass), \
					 GMAIL_TYPE_LIST))
#define GMAIL_LIST_GET_CLASS(obj) 	(G_TYPE_INSTANCE_GET_CLASS ((obj), \
				         GMAIL_TYPE_LIST, GmailListClass))

typedef struct _GmailList 		GmailList;
typedef struct _GmailListClass 		GmailListClass;
typedef struct _GmailListPrivate 	GmailListPrivate;

/** 
 * This struct holds all data for the GmailList class.
 */
struct _GmailList {
	GObject parent;
	GmailListPrivate *priv;
};

/** 
 * This class represents a container for GmailAccounts.
 */
struct _GmailListClass {
	GObjectClass parent_class;

	/* signals */
	void (*changed)(GmailList *lst);
};

/* the standard GObject functions.. */
GType 
gmail_list_get_type (void);
GType 
gmail_list_register_type (GTypeModule *module);

/** 
 * gmail_list_append_account:
 * 
 * @list: a pointer to a GmailList
 * @acc: a pointer to a GmailAccount
 *
 * This function appends a GmailAccount to the GmailList object.
 *
 */
void
gmail_list_append_account (GmailList *list, GmailAccount *acc);
/** 
 * gmail_list_remove_account:
 * 
 * @list: a pointer to a GmailList.
 * @acc: a pointer to a GmailAccount.
 *
 * This function removes a GmailAccount from the GmailList object.
 *
 */
void
gmail_list_remove_account (GmailList *list, GmailAccount *acc);
/** 
 * gmail_list_remove_account_by_mail:
 * 
 * @list: is a pointer to a GmailList object.
 * @mail: is a string which contains a gmail-address.
 *
 * This function removes a GmailAccount from the GmailList object, which has the
 * corresponding gmail-address.
 *
 */
void
gmail_list_remove_account_by_mail (GmailList *list, char *mail);
/** 
 * gmail_list_emit_changed:
 * 
 * @list: is a pointer to a GmailList.
 *
 * This function emits the gmail-list-changed signal which indicates that either
 * the GmailList object or one of the GmailAccount objects in the GmailList
 * object has changed.
 *
 */
void 
gmail_list_emit_changed (GmailList *list);
/** 
 * gmail_list_find_account:
 * 
 * @list: is a pointer to a GmailList
 * @mail: is a string which includes a gmail-address. 
 * 
 * This function finds a GmailAccount which has the corresponding mail-address.
 *
 * Returns: a pointer to a GmailAccount
 */
GmailAccount *
gmail_list_find_account (GmailList *list, char *mail);

void
gmail_list_foreach (GmailList *list, GFunc fun, void *user_data);

/** 
 * gmail_list_login:  
 *
 * @list: is the GmailList which holds the accounts, which should be logged
 * in.
 *
 * This function creates a new thread, and loggs each of the stored
 * accounts in.
 *
 */
void 
gmail_list_login (GmailList *list);

/** 
 * gmail_list_check: 
 * 
 * @list: is a pointer to a GmailList
 *
 * This function checks if the gmail accounts are logged in.
 * When the accounts are logged in a signal is emitted. 
 *
 * Returns: Always false
 */
gboolean
gmail_list_check (GmailList *list);

GmailList * 
gmail_list_new (void);

G_END_DECLS

#endif /* _GMAIL_LIST */
